Skip to content

feat: add external secret sources for variables - #4861

Draft
kmendell wants to merge 15 commits into
mainfrom
feat/extensible-external-secrets
Draft

kmendell wants to merge 15 commits into
mainfrom
feat/extensible-external-secrets

Conversation

@kmendell

@kmendell kmendell commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Checklist

  • This PR is not opened from my fork's main branch
  • All new user-facing strings are translated via Paraglide (m.*())

What This PR Implements

Arcane can now pull variables from an external secrets manager, store them as variables, and sync them to environments and agents. Each source is described by a YAML definition, so a new provider needs a definition file and no new Go code.

Shipped presets: Infisical, Doppler, Vault KV v2 (AppRole and token auth), 1Password Connect, generic HTTP JSON, and generic container. Custom definitions can be pasted in and validated before saving.

Addresses discussion #4036 (external secrets managers). This is a discussion, not an issue, so there is no issue number to close.

Changes Made

  • Backend domain: backend/internal/variable/children/source adds create, read, update, delete, refresh, test, definition validation, and preset listing under /api/variables/sources.
  • Fetch engine: backend/pkg/secretsource parses definitions, fetches over HTTP or from a container, extracts keys, renders templates, and loads presets from backend/resources/secretsources/*.yaml.
  • Scope: a source applies to all environments or to a selected set, stored through environment.ReplaceScopeRows.
  • Webhooks: a source can be refreshed by webhook, using target type secretsource.
  • Permissions: six secret-sources:* permissions (list, read, create, update, delete, refresh) in the authz catalog.
  • Migration 00117: creates secret_sources and secret_source_environments. It also grants the new permissions to roles and API keys that already hold every prior permission (full admins). Partial roles and keys get nothing. The down migration removes the tables, the grants, and the webhooks targeting sources.
  • Outbound fetch: backend/pkg/httpx/safe_remote.go is reworked for remote source fetches.
  • Shared regex: projects.EnvKeyPattern replaces a duplicate regex in the lifecycle service.
  • CLI: arcane variables sources commands in cli/pkg/variables/sources.go.
  • Frontend: a Secrets page with a table, create and edit sheet, refresh, and delete. The variables table and form are updated, and the environment scope select is new. Services, query keys, and types are added. All strings go through Paraglide.

Testing Done

  • TestMigration117_AddsSecretSourcesAndGrantsFullAdmins covers the up migration, full-admin grants, partial role and key exclusion, name uniqueness, and the down migration.
  • TestMigration102_CleansUpRBACPermissions now migrates to 117.
  • New service tests in backend/internal/variable/children/source/service_test.go.
  • backend/internal/variable/service_test.go is updated for the new variable flow.

Not verified yet:

  • The Secrets page has not been opened in a browser.
  • No live fetch has been run against real Infisical, Doppler, Vault, or 1Password instances.

AI Tool Used (if applicable)

Additional Context

  • Review migration 00117 first. Existing full-admin roles and API keys gain the six secret-sources:* permissions automatically.
  • Credentials are stored encoded and are never returned by the list or get endpoints.
  • Route, API paths, and permission IDs follow the secret-sources naming in the code.

Disclaimer Greptiles Reviews use AI, make sure to check over its work.

To better help train Greptile on our codebase, if the comment is useful and valid Like the comment, if its not helpful or invalid Dislike

To have Greptile Re-Review the changes, mention greptileai.

Confidence Score: 4/5 · The Go guide requirements must be satisfied before merging; the duplicate-key preview bug is also worth fixing.RetriggerView in GreptileConfidence Score: 4/5 Tier: plus

The Go guide requirements must be satisfied before merging; the duplicate-key preview bug is also worth fixing.

FindingsFix All in Claude CodeFindings

  1. P2 Trimmed keys break test previews ▶
  2. P2 DTOs skip required field checks ▶
  3. P2 Error checks skip required helper ▶
  4. P2 Flag errors go unexplained. ▶
  5. P2 Imports break the Go guide. ▶
  6. P2 Scope helper skips options. ▶
Fix with agent prompt
### Issue 1
backend/internal/variable/children/source/service.go:455-462
**Trimmed keys break test previews.** A response such as `{"TOKEN":"one"," TOKEN ":"two"}` passes through `extract` as two different keys. This loop trims both to `TOKEN` and keeps both. `Test` then returns duplicate names, but the sheet uses each name as a unique row key, causing a rendering error. Reject invalid raw names or deduplicate after trimming.

### Issue 2
backend/internal/variable/children/source/service.go:622
**DTOs skip required field checks.** `toDTO` returns a full `types.SecretSource` literal without `//exhaustruct:enforce`. The Go guide requires that marker on DTO and record mappings so added fields cannot be silently missed. Add it here and on the `updated` record literal; other new mappings have the same gap.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

### Issue 3
backend/pkg/secretsource/http.go:174-177
**Error checks skip required helper.** This branch uses a predeclared `urlErr` plus `errors.As`. The Go guide requires `errors.AsType` instead. The module already targets Go 1.27.4, so use the required helper here.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

### Issue 4
cli/pkg/variables/sources.go:undefined-268
This new call discards the error from `MarkFlagRequired` without explanation. The Go guide requires handling every error or adding a comment explaining why it can be ignored. Handle it, or document that `bindSourceFlags` already registered the flag.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

### Issue 5
backend/pkg/secretsource/container.go:undefined-15
`container.go` renames `github.com/containerd/errdefs` to `cerrdefs`, but no other import conflicts with `errdefs`. The repository guide requires default import names and allows aliases only to fix a real conflict. Remove this alias and use `errdefs.IsNotFound`.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

### Issue 6
backend/internal/environment/scope.go:undefined-61
`NormalizeScope` is newly public with four arguments, including the `allEnvironments` flag. The repository guide requires an options struct instead of boolean flags or long argument lists on exported functions. Put the scope settings in an options struct and update its callers.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds external secret sources that fetch variables from HTTP APIs or temporary containers, then share them with selected environments.

  • Arcane fetches variables through reusable secret source definitions.
  • Environment sync includes values from sources that apply there.
  • Operators can manage external sources from the Variables page or CLI.
  • Source refreshes can use webhooks and source permissions follow role access.

kmendell manually resolved the earlier response-close finding without explanation. Static review only; no tests, browser checks, or live-provider checks were run.

Reviews (14) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

@kmendell
kmendell requested a review from a team November 18, 2026 00:35
Comment thread cli/pkg/variables/sources.go Resolved
Comment thread cli/pkg/variables/sources.go Resolved
Comment thread backend/pkg/secretsource/http.go Resolved
- Add secret sources that sync key/value pairs from Doppler, Infisical, Vault, 1Password Connect, and generic HTTP or container providers into variables
- Scope each source to all environments or selected ones
- Keep credentials out of API responses
- Add migration 00117 granting secret-sources permissions to full admins and their API keys
- Add secret source API routes, `/secrets` page, and CLI `variables sources` commands
- Require secret sources create permission to test an unsaved source
- Require update permission only when a saved test changes fetch settings
- Update saved sources by ID and return not found when no row matches
- Add a switch to clear a saved optional credential in the source form
- Reset the refresh button's loading state before showing the result
- Print JSON from `secrets sources test` when JSON output is enabled
- Check the error from w.Write in serveSecrets instead of discarding it
- Panic on failure so lint no longer flags the ignored error
- Move external secret sources into a Secrets tab on the Variables page
- Remove the standalone /secrets route, its sidebar entry, and its auth prefix
- Gate the Variables page on variables or secret-sources permissions and show each tab only when its permission is granted
- Rename the Variables nav item and page to "Variables & Secrets"
- Wrap the variables page parallel loads in tryCatch
- Route load failures through throwPageLoadError so the page error boundary renders them
@kmendell
kmendell force-pushed the feat/extensible-external-secrets branch from 05d7b71 to 0cfc6d4 Compare November 18, 2026 20:51
…nal-secrets

# Conflicts:
#	backend/internal/database/database_test.go
#	frontend/messages/en.json
Comment thread backend/pkg/secretsource/container.go Resolved
},
}
bindSourceFlags(command, &opts)
_ = command.MarkFlagRequired("name")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Flag errors go unexplained. This new call discards the error from MarkFlagRequired without explanation. The Go guide requires handling every error or adding a comment explaining why it can be ignored. Handle it, or document that bindSourceFlags already registered the flag.

Rule Used: --- name: go-struct-literals description: Write Go 1.27+ in a declarative, composite-literal style. Every value (structs, slices, maps, configs, errors, servers, test tables, constructor results) is built with one keyed composite literal instead of f... (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: cli/pkg/variables/sources.go
Line: 283

Comment:
**Flag errors go unexplained.** This new call discards the error from `MarkFlagRequired` without explanation. The Go guide requires handling every error or adding a comment explaining why it can be ignored. Handle it, or document that `bindSourceFlags` already registered the flag.

**Rule Used:** --- name: go-struct-literals description: Write Go 1.27+ in a declarative, composite-literal style. Every value (structs, slices, maps, configs, errors, servers, test tables, constructor results) is built with one keyed composite literal instead of f... ([source](https://app.greptile.com/-/switch-tenant?tenant=getarcaneapp&next=%2Fcustom-context%3Fmemory%3D214b40a8-9695-4738-986d-5949b5d65ff1))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Codex Fix in Claude Code

…nal-secrets

# Conflicts:
#	frontend/src/lib/components/sheets/webhook-form-sheet.svelte
#	frontend/src/routes/(app)/projects/variables/+page.svelte
Comment thread cli/pkg/variables/sources.go Resolved
"strings"
"time"

cerrdefs "github.com/containerd/errdefs"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Imports break the Go guide. container.go renames github.com/containerd/errdefs to cerrdefs, but no other import conflicts with errdefs. The repository guide requires default import names and allows aliases only to fix a real conflict. Remove this alias and use errdefs.IsNotFound.

Context Used: AGENTS.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: backend/pkg/secretsource/container.go
Line: 17

Comment:
**Imports break the Go guide.** `container.go` renames `github.com/containerd/errdefs` to `cerrdefs`, but no other import conflicts with `errdefs`. The repository guide requires default import names and allows aliases only to fix a real conflict. Remove this alias and use `errdefs.IsNotFound`.

**Context Used:** AGENTS.md ([source](https://github.com/getarcaneapp/arcane/blob/main/AGENTS.md))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Codex Fix in Claude Code

- Rename secret-sources:* permissions to variables:sources:* in the authz catalog, access policy, routes, webhook refresh mapping, and frontend permission checks
- Update migration 00118 and its tests to the new permission strings (feature is unreleased)
- Remove the separate "External Secrets" permission resource
- List its actions under Variables as sources-list through sources-refresh
- Relabel them "... external secrets" and update the Variables description
- Drop saved credentials when the preset, custom YAML, base URL, or container inputs change, and ask the user to re-enter them
- Serialize secret source updates with the fetch lock and refetch after saving
- Check environment scope under the fetch lock when building effective layers
- Remove secret source containers along with their volumes
- CLI: accept CRLF line endings in credentials files
- Preload each source's environments in EffectiveLayers
- Skip sources that are not all-environments and not assigned to the requested environment
- Move scope replacement and validation into shared environment helpers (ScopeTable, NormalizeScope, ResolveScope)
- Global variables and secret sources use the same scope code
- Detect duplicate secret source names from the DB error instead of a pre-check
- Keep stored credentials only for fields the definition still declares, and drop them when the source is retargeted
- Record fetch status and refresh the source cache under the per-source lock
return nil
}

func NormalizeScope(ctx context.Context, db *database.DB, allEnvironments bool, envIDs []string) ([]string, error) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Scope helper skips options. NormalizeScope is newly public with four arguments, including the allEnvironments flag. The repository guide requires an options struct instead of boolean flags or long argument lists on exported functions. Put the scope settings in an options struct and update its callers.

Context Used: AGENTS.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: backend/internal/environment/scope.go
Line: 61

Comment:
**Scope helper skips options.** `NormalizeScope` is newly public with four arguments, including the `allEnvironments` flag. The repository guide requires an options struct instead of boolean flags or long argument lists on exported functions. Put the scope settings in an options struct and update its callers.

**Context Used:** AGENTS.md ([source](https://github.com/getarcaneapp/arcane/blob/main/AGENTS.md))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Codex Fix in Claude Code

@kmendell
kmendell marked this pull request as draft November 23, 2026 02:58
…nal-secrets

# Conflicts:
#	backend/internal/database/database_test.go
#	backend/internal/webhook/service.go
#	backend/pkg/httpx/safe_remote.go
#	frontend/messages/en.json
Comment on lines +455 to +462
accepted := make([]types.EnvVariable, 0, len(entries))
for _, entry := range entries {
key := config.keyPrefix + strings.TrimSpace(entry.Key)
if projects.EnvKeyPattern.MatchString(key) {
accepted = append(accepted, types.EnvVariable{
Key: key,
Value: entry.Value,
})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Trimmed keys break test previews. A response such as {"TOKEN":"one"," TOKEN ":"two"} passes through extract as two different keys. This loop trims both to TOKEN and keeps both. Test then returns duplicate names, but the sheet uses each name as a unique row key, causing a rendering error. Reject invalid raw names or deduplicate after trimming.

Prompt To Fix With AI
This is a comment left during a code review.
Path: backend/internal/variable/children/source/service.go
Line: 455-462

Comment:
**Trimmed keys break test previews.** A response such as `{"TOKEN":"one"," TOKEN ":"two"}` passes through `extract` as two different keys. This loop trims both to `TOKEN` and keeps both. `Test` then returns duplicate names, but the sheet uses each name as a unique row key, causing a rendering error. Reject invalid raw names or deduplicate after trimming.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code

if err != nil {
return types.SecretSource{}, err
}
return types.SecretSource{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 DTOs skip required field checks. toDTO returns a full types.SecretSource literal without //exhaustruct:enforce. The Go guide requires that marker on DTO and record mappings so added fields cannot be silently missed. Add it here and on the updated record literal; other new mappings have the same gap.

Context Used: AGENTS.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: backend/internal/variable/children/source/service.go
Line: 622

Comment:
**DTOs skip required field checks.** `toDTO` returns a full `types.SecretSource` literal without `//exhaustruct:enforce`. The Go guide requires that marker on DTO and record mappings so added fields cannot be silently missed. Add it here and on the `updated` record literal; other new mappings have the same gap.

**Context Used:** AGENTS.md ([source](https://github.com/getarcaneapp/arcane/blob/main/AGENTS.md))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code

Comment on lines +174 to +177
var urlErr *url.Error
if errors.As(err, &urlErr) {
err = urlErr.Err
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Error checks skip required helper. This branch uses a predeclared urlErr plus errors.As. The Go guide requires errors.AsType instead. The module already targets Go 1.27.4, so use the required helper here.

Rule Used: --- name: go-struct-literals description: Write Go 1.27+ in a declarative, composite-literal style. Every value (structs, slices, maps, configs, errors, servers, test tables, constructor results) is built with one keyed composite literal instead of f... (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: backend/pkg/secretsource/http.go
Line: 174-177

Comment:
**Error checks skip required helper.** This branch uses a predeclared `urlErr` plus `errors.As`. The Go guide requires `errors.AsType` instead. The module already targets Go 1.27.4, so use the required helper here.

**Rule Used:** --- name: go-struct-literals description: Write Go 1.27+ in a declarative, composite-literal style. Every value (structs, slices, maps, configs, errors, servers, test tables, constructor results) is built with one keyed composite literal instead of f... ([source](https://app.greptile.com/-/switch-tenant?tenant=getarcaneapp&next=%2Fcustom-context%3Fmemory%3D214b40a8-9695-4738-986d-5949b5d65ff1))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code

…nal-secrets

# Conflicts:
#	backend/internal/database/database_test.go
#	backend/internal/webhook/service.go
#	frontend/messages/en.json
#	frontend/src/routes/(app)/projects/variables/+page.svelte
…nal-secrets

# Conflicts:
#	backend/internal/database/database_test.go
#	frontend/messages/en.json

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants